package com.haixee.parkdemo.common.response;

import com.haixee.parkdemo.common.context.WebContextHolder;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 日志 实体类
 *
 * @author RUIFENG GUO
 * 2020/3/26 10:57
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CommonLog {

    /**
     * 请求 proto
     */
    private String proto;

    /**
     * IP
     */
    private String ip;

    /**
     * 请求耗时
     */
    private double latency;

    /**
     * 请求 method
     */
    private String method;

    /**
     * 请求 url
     */
    private String url;

    /**
     * 请求状态码
     */
    private Integer code;

    /**
     * 提示信息
     */
    private String msg;

    /**
     * userAgent
     */
    private String userAgent;

    /**
     * 请求时间
     */
    private Date time;

    @Override
    public String toString() {
        return "uid=" + WebContextHolder.getUid() + ", proto=" + this.getProto() + ", ip=" + WebContextHolder.getIp() + ", latency=" + this.getLatency() + ", method=" + this.getMethod() + ", url=" + this.getUrl() + ", code=" + this.getCode() + ", msg=" + this.getMsg() + ", userAgent=" + this.getUserAgent() + ", time=" + this.getTime();
    }
}
